package com.zzq.demo.hibernate.service.impl;

import com.zzq.demo.hibernate.entity.Model;
import com.zzq.demo.hibernate.mapper.ModelMapper;
import com.zzq.demo.hibernate.service.ModelService;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : zhaoziqian
 * @description :
 * @date : 2019/9/11 17:40
 */
@Service
public class ModelServiceImpl implements ModelService {

    @Resource
    private ModelMapper modelMapper;

    @Override
    public void insertModel(Model model) {
        modelMapper.save(model);
    }

    @Override
    public List<Model> findAll() {
        return modelMapper.findAll();
    }

    @Override
    public void updateModel(Long id, Model model) {
        model.setId(id);
        modelMapper.save(model);
    }

    @Override
    public void deleteModel(Long id) {
        modelMapper.deleteById(id);
    }
}
